/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.frontends.owlxml;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public class AxiomLoader {
    public static xowl.lang.owl2.Axiom load(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        String name = node.getNodeName();
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDeclaration)) return load_Declaration(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointClasses)) return load_DisjointClasses(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointUnion)) return load_DisjointUnion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentClasses)) return load_EquivalentClasses(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubClassOf)) return load_SubClassOf(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyDomain)) return load_DataPropertyDomain(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyRange)) return load_DataPropertyRange(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointDataProperties)) return load_DisjointDataProperties(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentDataProperties)) return load_EquivalentDataProperties(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomFunctionalDataProperty)) return load_FunctionalDataProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubDataPropertyOf)) return load_SubDataPropertyOf(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDatatypeDefinition)) return load_DatatypeDefinition(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomClassAssertion)) return load_ClassAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDataPropertyAssertion)) return load_DataPropertyAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDifferentIndividuals)) return load_DifferentIndividuals(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomNegativeDataPropertyAssertion)) return load_NegativeDataPropertyAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomNegativeObjectPropertyAssertion)) return load_NegativeObjectPropertyAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyAssertion)) return load_ObjectPropertyAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSameIndividual)) return load_SameIndividual(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAsymmetricObjectProperty)) return load_AsymmetricObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomDisjointObjectProperties)) return load_DisjointObjectProperties(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomEquivalentObjectProperties)) return load_EquivalentObjectProperties(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomFunctionalObjectProperty)) return load_FunctionalObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomInverseFunctionalObjectProperty)) return load_InverseFunctionalObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomInverseObjectProperties)) return load_InverseObjectProperties(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomIrreflexiveObjectProperty)) return load_IrreflexiveObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyDomain)) return load_ObjectPropertyDomain(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomObjectPropertyRange)) return load_ObjectPropertyRange(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomReflexiveObjectProperty)) return load_ReflexiveObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubObjectPropertyOf)) return load_SubObjectPropertyOf(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSymmetricObjectProperty)) return load_SymmetricObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomTransitiveObjectProperty)) return load_TransitiveObjectProperty(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomHasKey)) return load_HasKey(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomSubAnnotationPropertyOf)) return load_SubAnnotationPropertyOf(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationPropertyDomain)) return load_AnnotationPropertyDomain(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationPropertyRange)) return load_AnnotationPropertyRange(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocOWL2.axiomAnnotationAssertion)) return load_AnnotationAssertion(ontologyLoader, node, context);
        if (name.equals(xowl.interpreter.frontends.VocActions.axiomFunctionDefinition)) return load_FunctionDefinition(ontologyLoader, node, context);
        return null;
    }

    private static List<org.w3c.dom.Node> load_Base(xowl.lang.owl2.Axiom axiom, OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        List<org.w3c.dom.Node> children = ExpressionLoader.getElements(node);
        AnnotationLoader.loadAnnotations(axiom, ontologyLoader, children, context);
        return children;
    }

    private static xowl.lang.owl2.Axiom load_Declaration(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.Declaration axiom = new xowl.lang.owl2.Declaration();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        org.w3c.dom.Node child = children.get(0);
        xowl.lang.owl2.IRI iri = ontologyLoader.getFullIRI(child);
        axiom.setEntity(iri);
        axiom.setType(child.getNodeName());
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointClasses(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DisjointClasses axiom = new xowl.lang.owl2.DisjointClasses();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointUnion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DisjointUnion axiom = new xowl.lang.owl2.DisjointUnion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(0), context));
        if (children.size() == 1)
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(1))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(1), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (int i=1; i!=children.size(); i++) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(ontologyLoader, children.get(i), context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentClasses(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.EquivalentClasses axiom = new xowl.lang.owl2.EquivalentClasses();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setClassSeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.ClassExpression> exps = new ArrayList<xowl.lang.owl2.ClassExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.ClassExpression temp = ExpressionLoader.loadClassExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setClassSeq(xowl.interpreter.impl.Sequences.toSequence_Class(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubClassOf(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SubClassOf axiom = new xowl.lang.owl2.SubClassOf();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(0), context));
        axiom.setSuperClass(ExpressionLoader.loadClassExp(ontologyLoader, children.get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_DataPropertyDomain(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DataPropertyDomain axiom = new xowl.lang.owl2.DataPropertyDomain();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DataPropertyRange(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DataPropertyRange axiom = new xowl.lang.owl2.DataPropertyRange();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        axiom.setDatarange(ExpressionLoader.loadDatarangeExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointDataProperties(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DisjointDataProperties axiom = new xowl.lang.owl2.DisjointDataProperties();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.DataPropertyExpression> exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.DataPropertyExpression temp = ExpressionLoader.loadDataPropExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentDataProperties(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.EquivalentDataProperties axiom = new xowl.lang.owl2.EquivalentDataProperties();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.DataPropertyExpression> exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.DataPropertyExpression temp = ExpressionLoader.loadDataPropExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionalDataProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.FunctionalDataProperty axiom = new xowl.lang.owl2.FunctionalDataProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubDataPropertyOf(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SubDataPropertyOf axiom = new xowl.lang.owl2.SubDataPropertyOf();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        axiom.setSuperDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_DatatypeDefinition(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DatatypeDefinition axiom = new xowl.lang.owl2.DatatypeDefinition();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDatatype(ExpressionLoader.loadDatarangeExp(ontologyLoader, children.get(0), context));
        axiom.setDatarange(ExpressionLoader.loadDatarangeExp(ontologyLoader, children.get(1), context));
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_ClassAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.ClassAssertion axiom = new xowl.lang.owl2.ClassAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DataPropertyAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DataPropertyAssertion axiom = new xowl.lang.owl2.DataPropertyAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(1), context));
        axiom.setValueLiteral(ExpressionLoader.loadLiteralExp(ontologyLoader, children.get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DifferentIndividuals(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DifferentIndividuals axiom = new xowl.lang.owl2.DifferentIndividuals();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setIndividualSeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.IndividualExpression> exps = new ArrayList<xowl.lang.owl2.IndividualExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.IndividualExpression temp = ExpressionLoader.loadIndividualExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setIndividualSeq(xowl.interpreter.impl.Sequences.toSequence_Ind(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_NegativeDataPropertyAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.NegativeDataPropertyAssertion axiom = new xowl.lang.owl2.NegativeDataPropertyAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setDataProperty(ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(1), context));
        axiom.setValueLiteral(ExpressionLoader.loadLiteralExp(ontologyLoader, children.get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_NegativeObjectPropertyAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.NegativeObjectPropertyAssertion axiom = new xowl.lang.owl2.NegativeObjectPropertyAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(1), context));
        axiom.setValueIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.ObjectPropertyAssertion axiom = new xowl.lang.owl2.ObjectPropertyAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(1), context));
        axiom.setValueIndividual(ExpressionLoader.loadIndividualExp(ontologyLoader, children.get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SameIndividual(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SameIndividual axiom = new xowl.lang.owl2.SameIndividual();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setIndividualSeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.IndividualExpression> exps = new ArrayList<xowl.lang.owl2.IndividualExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.IndividualExpression temp = ExpressionLoader.loadIndividualExp(ontologyLoader, child, context);
                if (temp != null) exps.add(temp);
            }
            axiom.setIndividualSeq(xowl.interpreter.impl.Sequences.toSequence_Ind(exps));
        }
        return axiom;
    }

    private static xowl.lang.owl2.Axiom load_AsymmetricObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.AsymmetricObjectProperty axiom = new xowl.lang.owl2.AsymmetricObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_DisjointObjectProperties(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.DisjointObjectProperties axiom = new xowl.lang.owl2.DisjointObjectProperties();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.ObjectPropertyExpression> exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.ObjectPropertyExpression temp = ExpressionLoader.loadObjPropExp(ontologyLoader, child, context);
                if(temp != null) exps.add(temp);
            }
            axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_EquivalentObjectProperties(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.EquivalentObjectProperties axiom = new xowl.lang.owl2.EquivalentObjectProperties();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        if (children.isEmpty())
            return axiom;
        if (ExpressionLoader.isToSeqNode(children.get(0))) {
            axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(0), context));
        } else {
            List<xowl.lang.owl2.ObjectPropertyExpression> exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
            for (org.w3c.dom.Node child : children) {
                xowl.lang.owl2.ObjectPropertyExpression temp = ExpressionLoader.loadObjPropExp(ontologyLoader, child, context);
                if(temp != null) exps.add(temp);
            }
            axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionalObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.FunctionalObjectProperty axiom = new xowl.lang.owl2.FunctionalObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_InverseFunctionalObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.InverseFunctionalObjectProperty axiom = new xowl.lang.owl2.InverseFunctionalObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_InverseObjectProperties(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.InverseObjectProperties axiom = new xowl.lang.owl2.InverseObjectProperties();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setInverse(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_IrreflexiveObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.IrreflexiveObjectProperty axiom = new xowl.lang.owl2.IrreflexiveObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyDomain(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.ObjectPropertyDomain axiom = new xowl.lang.owl2.ObjectPropertyDomain();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ObjectPropertyRange(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.ObjectPropertyRange axiom = new xowl.lang.owl2.ObjectPropertyRange();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_ReflexiveObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.ReflexiveObjectProperty axiom = new xowl.lang.owl2.ReflexiveObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubObjectPropertyOf(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SubObjectPropertyOf axiom = new xowl.lang.owl2.SubObjectPropertyOf();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        axiom.setSuperObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SymmetricObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SymmetricObjectProperty axiom = new xowl.lang.owl2.SymmetricObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_TransitiveObjectProperty(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.TransitiveObjectProperty axiom = new xowl.lang.owl2.TransitiveObjectProperty();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setObjectProperty(ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(0), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_HasKey(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.HasKey axiom = new xowl.lang.owl2.HasKey();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setClasse(ExpressionLoader.loadClassExp(ontologyLoader, children.get(0), context));
        if (children.size() == 1)
            return axiom;
        int next = 1;
        // Look for Object Property Sequence
        if (ExpressionLoader.isToSeqNode(children.get(1))) {
            axiom.setObjectPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(1), context));
            next++;
        } else {
            // Lookup Object Properties
            List<xowl.lang.owl2.ObjectPropertyExpression> exps = null;
            while (true) {
                if (children.size() == next)
                    return axiom;
                if (ExpressionLoader.isToSeqNode(children.get(next)))
                    break;
                xowl.lang.owl2.ObjectPropertyExpression exp = ExpressionLoader.loadObjPropExp(ontologyLoader, children.get(next), context);
                if (exp == null)
                    break;
                if (exps == null)
                    exps = new ArrayList<xowl.lang.owl2.ObjectPropertyExpression>();
                exps.add(exp);
                next++;
            }
            if (exps != null)
                axiom.setObjectPropertySeq(xowl.interpreter.impl.Sequences.toSequence_ObjProp(exps));
        }
        // Lookup for Data Property Sequence
        if (ExpressionLoader.isToSeqNode(children.get(next))) {
            axiom.setDataPropertySeq(ExpressionLoader.load_ToSeq(ontologyLoader, children.get(next), context));
        } else {
            // Loopup Data Properties
            List<xowl.lang.owl2.DataPropertyExpression> exps = null;
            while (true) {
                if (children.size() == next)
                    return axiom;
                xowl.lang.owl2.DataPropertyExpression exp = ExpressionLoader.loadDataPropExp(ontologyLoader, children.get(next), context);
                if (exp == null)
                    break;
                if (exps == null)
                    exps = new ArrayList<xowl.lang.owl2.DataPropertyExpression>();
                exps.add(exp);
                next++;
            }
            if (exps != null)
                axiom.setDataPropertySeq(xowl.interpreter.impl.Sequences.toSequence_DataProp(exps));
        }
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_SubAnnotationPropertyOf(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.SubAnnotationPropertyOf axiom = new xowl.lang.owl2.SubAnnotationPropertyOf();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(ontologyLoader, children.get(0), context));
        axiom.setSuperAnnotProperty(AnnotationLoader.loadAnnotationProperty(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationPropertyDomain(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.AnnotationPropertyDomain axiom = new xowl.lang.owl2.AnnotationPropertyDomain();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(ontologyLoader, children.get(0), context));
        axiom.setAnnotDomain(AnnotationLoader.loadAnnotationIRI(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationPropertyRange(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.AnnotationPropertyRange axiom = new xowl.lang.owl2.AnnotationPropertyRange();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(ontologyLoader, children.get(0), context));
        axiom.setAnnotRange(AnnotationLoader.loadAnnotationIRI(ontologyLoader, children.get(1), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_AnnotationAssertion(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.owl2.AnnotationAssertion axiom = new xowl.lang.owl2.AnnotationAssertion();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setAnnotProperty(AnnotationLoader.loadAnnotationProperty(ontologyLoader, children.get(0), context));
        axiom.setAnnotSubject(AnnotationLoader.loadAnnotationSubject(ontologyLoader, children.get(1), context));
        axiom.setAnnotValue(AnnotationLoader.loadAnnotationValue(ontologyLoader, children.get(2), context));
        return axiom;
    }
    private static xowl.lang.owl2.Axiom load_FunctionDefinition(OntologyLoader ontologyLoader, org.w3c.dom.Node node, xowl.interpreter.frontends.LexicalContext context) {
        xowl.lang.actions.FunctionDefinition axiom = new xowl.lang.actions.FunctionDefinition();
        List<org.w3c.dom.Node> children = load_Base(axiom, ontologyLoader, node, context);
        axiom.setFunction(ExpressionLoader.loadFunctionExp(ontologyLoader, children.get(0), context));
        axiom.setBehavior(ExpressionLoader.loadExecutableExp(ontologyLoader, children.get(1), context));
        return axiom;
    }
}
